﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedGenomics.Domain
{
    public static class MapFactory
    {
        public static Func<S, D> CreateMap<S, D>(IEnumerable<KeyValuePair<S, D>> mappings)
        {
            Dictionary<S, D> dict = new Dictionary<S, D>();

            if (mappings != null)
            {
                foreach (var kvp in mappings)
                {
                    ((IDictionary<S, D>)dict).Add(kvp);
                }
            }

            return s => dict.ContainsKey(s) ? dict[s] : default(D);
        }
    }
}
